package com.wyc.service.impl;

import com.wyc.dao.HouseholdInformationSheetMapper;
import com.wyc.pojo.HouseholdInformationSheet;
import com.wyc.service.HouseholdInformationSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName HouseholdInformationSheetImp
 * @Author 王韫琛
 * @Date 2021/1/18 14:16
 * @Version 1.0
 */
@Service
public class HouseholdInformationSheetImp implements HouseholdInformationSheetService {
    @Autowired
    private HouseholdInformationSheetMapper householdInformationSheetMapper;
    //普通管理员添加住户信息
    @Override
    public int addHouseInformation(HouseholdInformationSheet householdInformationSheet) {
        return householdInformationSheetMapper.addHouseInformation(householdInformationSheet);
    }
    //普通管理员查看用户身份证是否存在
    @Override
    public HouseholdInformationSheet findByCertificateNumber(String certificate_number) {
        System.out.println(certificate_number);
        return householdInformationSheetMapper.findByCertificateNumber(certificate_number);
    }
    //普通管理员检查手机号是否存在
    @Override
    public HouseholdInformationSheet findByCellPhoneNumber(String cell_phone_number) {
        return householdInformationSheetMapper.findByCellPhoneNumber(cell_phone_number);
    }
    //获取household_information_sheet表中得所有数据
    @Override
    public int getTotal() {
        return householdInformationSheetMapper.getTotal();
    }
    //分页查询所有数据的方法
    @Override
    public List<HouseholdInformationSheet> findPage(Integer pageNum, Integer pageSize) {
        pageNum = (pageNum-1)*pageSize;
        List<HouseholdInformationSheet> list = householdInformationSheetMapper.queryAllUser(pageNum, pageSize);
        return list;
    }
    //根据身份证查询用户信息
    @Override
    public List<HouseholdInformationSheet> selectByCertificateNumber(String certificate_number) {
        return householdInformationSheetMapper.selectByCertificateNumber(certificate_number);
    }
    //根据id删除用户
    @Override
    public int deleteHouseholdInformationSheetById(Integer id) {
        return householdInformationSheetMapper.deleteHouseholdInformationSheetById(id);
    }
    //更新用户信息
    @Override
    public int updateHouseholdInformationSheet(HouseholdInformationSheet householdInformationSheet) {
        System.out.println(householdInformationSheetMapper.updateHouseholdInformationSheet(householdInformationSheet));
        return householdInformationSheetMapper.updateHouseholdInformationSheet(householdInformationSheet);
    }
}
